﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public class Admin_DAL
    {
        public Admin_DAL(Context context)
        {
            Context = context;
        }

        public Context Context { get; }


        /// <summary>
        /// 管理员登录
        /// </summary>
        /// <param name="Name"></param>
        /// <param name="Pwd"></param>
        /// <returns></returns>
        public int Login(string? Name, string? Pwd)
        {
            var m=Context.Admin_Model.FirstOrDefault(x=>x.Name == Name);
            if (m == null)
            {
                return -1; //没有此账号，请重新输入
            }
            else
            {
                if (m.Pwd == Pwd)
                {
                    return m.Id;
                }
                else
                {
                    return -2; //密码错误
                }
            }
        }




    }
}
